<!DOCTYPE html>
<html class="pixel-ratio-1">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  <title>登录</title>

  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no, email=no">
  <!--[if IE]>
  <script src="http://127.0.0.1:80/wx/ybss/js/html5shiv.min.js"></script>
  <![endif]-->

  <link href="../../resource/style.css" rel="stylesheet" type="text/css">
  <link type="text/css" rel="stylesheet" href="../../resource/fapiao.css">
  <link rel="stylesheet" href="../../resource/weuimin.css" />
  <link rel="stylesheet" href="../../resource/example.css" />
  <script src="../../resource/md5.js"></script>
  <script src="../../resource/jquery214.js"></script>
  <script src="../../resource/fastclick.js"></script>
  <script src="../../resource/jqueryweui.js"></script>
  <script src="../../resource/zeptomin.js">
  </script><script src="../../resource/picker.js"></script>
  <script src="../../resource/api.js"></script>
  <script src="../../resource/jquery1.js"></script>
<script src="../../resource/ystfiles/qrcode.js"></script>
  <script src="../../resource/jquerybarcode.js"></script>
  <script src="../../script/api.js"></script>
  <script type="text/javascript" src="../../script/constants.js"></script>
  <script type="text/javascript" src="../../script/tmd5.js"></script>
  <script type="text/javascript" src="../../script/aes.js"></script>
  <script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
  <script type="text/javascript" src="../../script/modeecb.js"></script>
  <style>
    .logo-license{margin-top:0px;}
    .left{font-weight:bold;}
    .info {margin-top: 5rem;border-width:0px;}
    .info ul{margin-top:1rem;}
    .info ul li{text-align:center;}
    html,.info{height:100%;}
    .info ul{width:96%;margin:0 auto;background:#FFF;margin-top:1rem;border-radius: 5px;box-shadow: #000 0 5px 5px -5px;}
    .info ul li div{width:80px;height:80px;background:blue;clear: both;margin:0 auto;border-radius: 40px;color:#FFF;line-height:75px;text-align:center;font-size:28px;}
    .weui-cell__bd p{font-size:14px;}
    .weui-cell__bd{min-width:165px;}




  </style>

</head>
<body style="background:#18b4ed;height:88%;">
<header id="statusBar">
  <img src="../../image/back.png" onclick="api.closeWin();" />
  <span style="text-align: center;width: 80%;margin: 0 auto;">支付开票</span>
  <div style="clear:both"></div>
</header>

<div style="height: 10px;"></div>


<article class="info" style=" margin-left: 6px;margin-right: 6px;padding: 1px;">
  <ul>
    <!-- 2017年7月26日10:03:59 by cph 二维码添加，更改布局 -->

    <!-- 条形码 -->
    <li  id="show" >
      <!--     <span id="barcode" ></span> -->
      <!-- 清除样式，所有!!!!! -->
      <div id="barcode" style="clear:both;border: none;border-radius:0px;background-color: #FFF" ></div>

      <p id="clickshownum" style="font-size: 14px;margin-top:4px;padding-bottom:4px;color: #B4B4B4;">
        
      </p>
      <!-- 二维码 -->
      <p id="test" style="font-size: 20px">
      正在生成二维码...
      </p>
      


      <p id="clickrefresh" style="margin-top:2px;padding-bottom:0px;color: #B4B4B4;" onclick="updateQr();">
        <img style="width:14px;height:14px; margin-bottom: -2px" src="../../image/refresh.png" id="refresh"/>
        <font style="font-size: 14px;"> 定时自动刷新 </font>
      </p>

    </li>

    <li style="text-align:left;font-size:14px;padding-left:1rem;padding-right:1rem;">
      
				<p style="font-size:14px;">名称：<i style="font-size:14px;" id="ymc"></i></p>
				<p style="font-size:14px;">税号：<i style="font-size:14px;" id="ysh"></i></p>
				<p style="font-size:14px;">地址：<i style="font-size:14px;" id="ydz"></i></p>
				<p style="font-size:14px;">电话：<i style="font-size:14px;" id="ydh"></i></p>
				<p style="font-size:14px;">开户行：<i style="font-size:14px;" id="yyh"></i></p>

      <!-- <a style="float:right;color:#B4B4B4;font-size:14px;" onclick="showCards();"></a>
       -->
    </li>


  </ul>
</article>




<div id="div_mask" style="display:none;background-color:#000;opacity: 0.6;overflow:hidden;position:absolute;top:0;left:0;right:0;bottom:0;z-index:998">&nbsp;</div>
<div id="div_confirm" style="display:none;position:absolute;bottom:0;right:0;left:0;min-height:300px;background-color:#fff;margin:10px;border-radius:8px;z-index:999">
  <div style="text-align:center;padding-top:10px;">
    <label style="font-size:16px;">选择银行卡</label>
    <a class="weui-btn weui-btn_default"
       style="right:10px;top:8px;position:absolute;color:#555;font-size:12px;" onclick="hideCards()">取消</a>
  </div>
  <div class="page__bd">
    <div class="weui-cells">
     
  </div>
</div>
</div>

<script>
  var _qr = '';
  var zfqrno = '';
  apiready = function(){
      if(api.systemType == "ios"){
		   document.getElementById("statusBar").style.background = "#298cb4";
	  }
      $api.fixStatusBar( $api.dom('header') );
      if(api.systemType=='ios'){
			api.addEventListener({
			    name:'takescreenshot'
			}, function(ret, err){     
			   alert('为了资金安全，请不要将该码转发给他人！');
			});
		 }
      var ymc = api.pageParam.ymc;
      var ysh = api.pageParam.ysh;
      var ydz = api.pageParam.ydz;
      var ydh = api.pageParam.ydh;
      var yyh = api.pageParam.yyh;
      _qr = api.pageParam.qr;
      $("#ymc").html(ymc);
      $("#ysh").html(ysh);
      $("#ydz").html(ydz);
      $("#ydh").html(ydh);
      $("#yyh").html(yyh);
      createQrcode();
  }
  
  var time;
  function createQrcode(){
		var dl_phone = $api.getStorage("dl_phone");
		if (typeof(dl_phone) == "undefined" || dl_phone == "undefined" || "" == dl_phone || dl_phone == null) {
			abc();
			return;
		}
		var ip = "0.0.0.0";
		var s = api.connectionType;
	    s = s.toLowerCase();
	    if (s == 'wifi' || s == '3g' || s == '4g' || s == '2g') {
		  var aeskey = api.loadSecureValue({
	        sync: true,
	        key: 'aeskey'
	      });
	      var salt = api.loadSecureValue({
	        sync: true,
	        key: 'salt'
	      });
	      var demo = api.require('ipAddress');
		demo.getIp({
		    isNetIp: true
		},function(ret, err) {
		    console.log(JSON.stringify(ret) + "   " + JSON.stringify(err));
		    if(ret.status){
		      ip = ret.ip;
		    }
	        var content = {"phone":dl_phone,"dlPhone":dl_phone,"ip":ip,"deviceID":$api.getStorage("openid")};
		    var callback = function(ret, err){
		        //console.log(JSON.stringify(ret));
		        if (ret) {
   			   var aeskey = api.loadSecureValue({
			      sync: true,
			      key: 'aeskey'
			    });
			    var salt = api.loadSecureValue({
			      sync: true,
			      key: 'salt'
			    });
			    
   			    $("#test").html("");
   			    var jyqr = "";
   			    if(ret.msg == "OK"){
   			        jyqr = Decrypt(ret.qrNo,aeskey);
			        var mysign = md5(jyqr+salt);
			        if(mysign == ret.sign){
			          setInterval("refrenshQr()",60000);
	   			      time = setInterval("zfNotify()",2000);
	   			      $("#clickshownum").html("该二维码可用于支付开票");
	     			}else{
		              alert("请求异常！");
		              api.closeWin();
		            }
   			      
   			    }else{
   			      //$api.toast('提示', '该二维码仅用于开票！', 2000);
   			      $("#clickshownum").html("该二维码仅用于开票");
   			    }
	    	    zfqrno = jyqr;
	    		var zfqrCode = "qrNo="+zfqrno +"&invoiceUserId="+ _qr;
	    		
	    			var myDate = new Date();
				var test = myDate.getTime();
	    	   


				var Num="";
				for(var i=0;i<6;i++)
				{
				Num+=Math.floor(Math.random()*10);
				}

				var lsh="QR"+test+Num;
	    	    var callback = function(ret, err){
			        //console.log(JSON.stringify(ret));
			    }
			    var content = {"lsh":lsh,"dl_phone":dl_phone};
			    apiAjax(JSON.stringify(content),url.seriaNumber,callback);
	    		
	    		var zfqrCode = "qrNo="+zfqrno +"&invoiceUserId="+ _qr+"&DoQr="+lsh;
	    		var qrcode = new QRCode("test", {
				    text: zfqrCode,
				    width: 200,
				    height: 200,
				    colorDark : "#000000",
				    colorLight : "#ffffff",
				    correctLevel : QRCode.CorrectLevel.H
				});
				 
				 //  //条形码绘制
                 barcode(zfqrCode);
			} else {
			    api.alert({msg:'网络异常'});
			}
		    }
		    encApiAjax(JSON.stringify(content),url.kpqr,callback);
		   });
		} else {
			   $api.toast('提示', '网络异常', 2000);
	    }	

		}
		
	function updateQr(){
	   refrenshQr();
	}
		
	function refrenshQr(){
		   var dl_phone = $api.getStorage("dl_phone");
		if (typeof(dl_phone) == "undefined" || dl_phone == "undefined" || "" == dl_phone || dl_phone == null) {
			abc();
			return;
		}
		var ip = "0.0.0.0";
		var s = api.connectionType;
	    s = s.toLowerCase();
	    if (s == 'wifi' || s == '3g' || s == '4g' || s == '2g') {
		  var aeskey = api.loadSecureValue({
	        sync: true,
	        key: 'aeskey'
	      });
	      var salt = api.loadSecureValue({
	        sync: true,
	        key: 'salt'
	      });
	      var content = {"dlPhone":dl_phone,"ip":ip,"deviceID":$api.getStorage("openid")};
	      var callback = function(ret, err){
	        //console.log(JSON.stringify(ret));
	        if (ret) {
   			   var aeskey = api.loadSecureValue({
			      sync: true,
			      key: 'aeskey'
			    });
			    var salt = api.loadSecureValue({
			      sync: true,
			      key: 'salt'
			    });
			    var jyqr = Decrypt(ret.qrNo,aeskey);
			    var mysign = md5(jyqr+salt);
   			   if(mysign == ret.sign){
   			    $("#test").html("");
	    	    zfqrno = jyqr;
	    		var zfqrCode = "qrNo="+zfqrno +"&invoiceUserId="+ _qr;
				var qrcode = new QRCode("test", {
				    text: zfqrCode,
				    width: 200,
				    height: 200,
				    colorDark : "#000000",
				    colorLight : "#ffffff",
				    correctLevel : QRCode.CorrectLevel.H
				});
				 
				 //  //条形码绘制
                 barcode(zfqrCode);
                 }else{
                   alert("请求异常");
                   api.closeWin();
                 }
			} else {
			    api.alert({msg:'网络异常'});
			}
	      }
	      var content = {"id":"9598fdeb-e52f-431e-8c65-65ff92dad57d","phone":"15680030061"};
	      encApiAjax(JSON.stringify(content),url.kpqr,callback);
		} else {
			      $api.toast('提示', '网络异常', 2000);
	    }	

		}

 
  function barcode(str){
    $("#barcode").html('');
    /* 绘制条形码 */
    $("#barcode").barcode(str, "code128",{
      width:0,
      output:'bmp',       //渲染方式 css/bmp/svg/canvas
      bgColor: '#ffffff', //条码背景颜色
      color: '#000000',   //条码颜色
      barWidth: 2,        //单条条码宽度
      barHeight: 80,     //单体条码高度
     // moduleSize: 1,   //条码大小
      // posX: 10,        //条码坐标X
      // posY: 5,         //条码坐标Y
      addQuietZone: false  //是否添加空白区（内边距）
    });

    //  $("#barcode").css('width', '60rem');
     $("#barcode").width(document.documentElement.clientWidth*0.9);

  }

  var num = 0;
function zfNotify(){
    var callback = function(data, err){
        //console.log(JSON.stringify(ret));
        if(data){
	        if (data.MSG == "成功") {	
	          //$api.toast('提示', '支付成功！', 2000);        
	          //window.location.href = '<%=basePath%>wx/unionPay/zfcg.jsp?id='+data.NO+'&amt='+data.AMT+'&zt=1'
	          var no = data.NO;
	          var je = data.AMT;
	          clearInterval(time);
	          api.openWin({
	              name: 'success',
	              url: 'success.html',
	              pageParam: {
						id:no,
						amt:je,
						zt:1
				  }
              });
	        }else{
	         //$api.toast('提示', '支付失败！', 2000);	
	          //window.location.href = '<%=basePath%>wx/unionPay/zfcg.jsp?msg='+data.MSG+'&zt=2'
	          clearInterval(time);
	          var msgc = data.MSG;
	          api.openWin({
	              name: 'success',
	              url: 'success.html',
	              pageParam: {
						msg:msgc,
						zt:2
				  }
              });
	        }
        }
    }
    var content = {"qrno":zfqrno};
    apiAjax(JSON.stringify(content),url.zczfjg,callback);
}


</script>


</body></html>